3.5.39 \(\int \cos (c+d x) (a+b \tan ^2(c+d x))^2 \, dx\) [439]

Optimal. Leaf size=62 \[ \frac {(4 a-3 b) b \tanh ^{-1}(\sin (c+d x))}{2 d}+\frac {(a-b)^2 \sin (c+d x)}{d}+\frac {b^2 \sec (c+d x) \tan (c+d x)}{2 d} \]

[Out]

1/2*(4*a-3*b)*b*arctanh(sin(d*x+c))/d+(a-b)^2*sin(d*x+c)/d+1/2*b^2*sec(d*x+c)*tan(d*x+c)/d

________________________________________________________________________________________

Rubi [A]
time = 0.06, antiderivative size = 62, normalized size of antiderivative = 1.00, number of steps used = 5, number of rules used = 4, integrand size = 21, \(\frac {\text {number of rules}}{\text {integrand size}}\) = 0.190, Rules used = {3757, 398, 393, 212} \begin {gather*} \frac {(a-b)^2 \sin (c+d x)}{d}+\frac {b (4 a-3 b) \tanh ^{-1}(\sin (c+d x))}{2 d}+\frac {b^2 \tan (c+d x) \sec (c+d x)}{2 d} \end {gather*}

Antiderivative was successfully verified.

[In]

Int[Cos[c + d*x]*(a + b*Tan[c + d*x]^2)^2,x]

[Out]

((4*a - 3*b)*b*ArcTanh[Sin[c + d*x]])/(2*d) + ((a - b)^2*Sin[c + d*x])/d + (b^2*Sec[c + d*x]*Tan[c + d*x])/(2*
d)

Rule 212

Int[((a_) + (b_.)*(x_)^2)^(-1), x_Symbol] :> Simp[(1/(Rt[a, 2]*Rt[-b, 2]))*ArcTanh[Rt[-b, 2]*(x/Rt[a, 2])], x]
 /; FreeQ[{a, b}, x] && NegQ[a/b] && (GtQ[a, 0] || LtQ[b, 0])

Rule 393

Int[((a_) + (b_.)*(x_)^(n_))^(p_)*((c_) + (d_.)*(x_)^(n_)), x_Symbol] :> Simp[(-(b*c - a*d))*x*((a + b*x^n)^(p
 + 1)/(a*b*n*(p + 1))), x] - Dist[(a*d - b*c*(n*(p + 1) + 1))/(a*b*n*(p + 1)), Int[(a + b*x^n)^(p + 1), x], x]
 /; FreeQ[{a, b, c, d, n, p}, x] && NeQ[b*c - a*d, 0] && (LtQ[p, -1] || ILtQ[1/n + p, 0])

Rule 398

Int[((a_) + (b_.)*(x_)^(n_))^(p_)*((c_) + (d_.)*(x_)^(n_))^(q_), x_Symbol] :> Int[PolynomialDivide[(a + b*x^n)
^p, (c + d*x^n)^(-q), x], x] /; FreeQ[{a, b, c, d}, x] && NeQ[b*c - a*d, 0] && IGtQ[n, 0] && IGtQ[p, 0] && ILt
Q[q, 0] && GeQ[p, -q]

Rule 3757

Int[sec[(e_.) + (f_.)*(x_)]^(m_.)*((a_) + (b_.)*tan[(e_.) + (f_.)*(x_)]^(n_))^(p_.), x_Symbol] :> With[{ff = F
reeFactors[Sin[e + f*x], x]}, Dist[ff/f, Subst[Int[ExpandToSum[b*(ff*x)^n + a*(1 - ff^2*x^2)^(n/2), x]^p/(1 -
ff^2*x^2)^((m + n*p + 1)/2), x], x, Sin[e + f*x]/ff], x]] /; FreeQ[{a, b, e, f}, x] && IntegerQ[(m - 1)/2] &&
IntegerQ[n/2] && IntegerQ[p]

Rubi steps

\begin {align*} \int \cos (c+d x) \left (a+b \tan ^2(c+d x)\right )^2 \, dx &=\frac {\text {Subst}\left (\int \frac {\left (a-(a-b) x^2\right )^2}{\left (1-x^2\right )^2} \, dx,x,\sin (c+d x)\right )}{d}\\ &=\frac {\text {Subst}\left (\int \left ((a-b)^2+\frac {(2 a-b) b-2 (a-b) b x^2}{\left (1-x^2\right )^2}\right ) \, dx,x,\sin (c+d x)\right )}{d}\\ &=\frac {(a-b)^2 \sin (c+d x)}{d}+\frac {\text {Subst}\left (\int \frac {(2 a-b) b-2 (a-b) b x^2}{\left (1-x^2\right )^2} \, dx,x,\sin (c+d x)\right )}{d}\\ &=\frac {(a-b)^2 \sin (c+d x)}{d}+\frac {b^2 \sec (c+d x) \tan (c+d x)}{2 d}+\frac {((4 a-3 b) b) \text {Subst}\left (\int \frac {1}{1-x^2} \, dx,x,\sin (c+d x)\right )}{2 d}\\ &=\frac {(4 a-3 b) b \tanh ^{-1}(\sin (c+d x))}{2 d}+\frac {(a-b)^2 \sin (c+d x)}{d}+\frac {b^2 \sec (c+d x) \tan (c+d x)}{2 d}\\ \end {align*}

________________________________________________________________________________________

Mathematica [B] Leaf count is larger than twice the leaf count of optimal. \(146\) vs. \(2(62)=124\).
time = 0.49, size = 146, normalized size = 2.35 \begin {gather*} \frac {-2 (4 a-3 b) b \log \left (\cos \left (\frac {1}{2} (c+d x)\right )-\sin \left (\frac {1}{2} (c+d x)\right )\right )+2 (4 a-3 b) b \log \left (\cos \left (\frac {1}{2} (c+d x)\right )+\sin \left (\frac {1}{2} (c+d x)\right )\right )+\frac {b^2}{\left (\cos \left (\frac {1}{2} (c+d x)\right )-\sin \left (\frac {1}{2} (c+d x)\right )\right )^2}-\frac {b^2}{\left (\cos \left (\frac {1}{2} (c+d x)\right )+\sin \left (\frac {1}{2} (c+d x)\right )\right )^2}+4 (a-b)^2 \sin (c+d x)}{4 d} \end {gather*}

Antiderivative was successfully verified.

[In]

Integrate[Cos[c + d*x]*(a + b*Tan[c + d*x]^2)^2,x]

[Out]

(-2*(4*a - 3*b)*b*Log[Cos[(c + d*x)/2] - Sin[(c + d*x)/2]] + 2*(4*a - 3*b)*b*Log[Cos[(c + d*x)/2] + Sin[(c + d
*x)/2]] + b^2/(Cos[(c + d*x)/2] - Sin[(c + d*x)/2])^2 - b^2/(Cos[(c + d*x)/2] + Sin[(c + d*x)/2])^2 + 4*(a - b
)^2*Sin[c + d*x])/(4*d)

________________________________________________________________________________________

Maple [A]
time = 0.19, size = 100, normalized size = 1.61

method result size
derivativedivides \(\frac {b^{2} \left (\frac {\sin ^{5}\left (d x +c \right )}{2 \cos \left (d x +c \right )^{2}}+\frac {\left (\sin ^{3}\left (d x +c \right )\right )}{2}+\frac {3 \sin \left (d x +c \right )}{2}-\frac {3 \ln \left (\sec \left (d x +c \right )+\tan \left (d x +c \right )\right )}{2}\right )+2 a b \left (-\sin \left (d x +c \right )+\ln \left (\sec \left (d x +c \right )+\tan \left (d x +c \right )\right )\right )+a^{2} \sin \left (d x +c \right )}{d}\) \(100\)
default \(\frac {b^{2} \left (\frac {\sin ^{5}\left (d x +c \right )}{2 \cos \left (d x +c \right )^{2}}+\frac {\left (\sin ^{3}\left (d x +c \right )\right )}{2}+\frac {3 \sin \left (d x +c \right )}{2}-\frac {3 \ln \left (\sec \left (d x +c \right )+\tan \left (d x +c \right )\right )}{2}\right )+2 a b \left (-\sin \left (d x +c \right )+\ln \left (\sec \left (d x +c \right )+\tan \left (d x +c \right )\right )\right )+a^{2} \sin \left (d x +c \right )}{d}\) \(100\)
risch \(-\frac {i {\mathrm e}^{i \left (d x +c \right )} a^{2}}{2 d}+\frac {i {\mathrm e}^{i \left (d x +c \right )} a b}{d}-\frac {i {\mathrm e}^{i \left (d x +c \right )} b^{2}}{2 d}+\frac {i {\mathrm e}^{-i \left (d x +c \right )} a^{2}}{2 d}-\frac {i {\mathrm e}^{-i \left (d x +c \right )} a b}{d}+\frac {i {\mathrm e}^{-i \left (d x +c \right )} b^{2}}{2 d}-\frac {i b^{2} \left ({\mathrm e}^{3 i \left (d x +c \right )}-{\mathrm e}^{i \left (d x +c \right )}\right )}{d \left ({\mathrm e}^{2 i \left (d x +c \right )}+1\right )^{2}}+\frac {2 \ln \left ({\mathrm e}^{i \left (d x +c \right )}+i\right ) a b}{d}-\frac {3 \ln \left ({\mathrm e}^{i \left (d x +c \right )}+i\right ) b^{2}}{2 d}-\frac {2 \ln \left ({\mathrm e}^{i \left (d x +c \right )}-i\right ) a b}{d}+\frac {3 \ln \left ({\mathrm e}^{i \left (d x +c \right )}-i\right ) b^{2}}{2 d}\) \(233\)

Verification of antiderivative is not currently implemented for this CAS.

[In]

int(cos(d*x+c)*(a+b*tan(d*x+c)^2)^2,x,method=_RETURNVERBOSE)

[Out]

1/d*(b^2*(1/2*sin(d*x+c)^5/cos(d*x+c)^2+1/2*sin(d*x+c)^3+3/2*sin(d*x+c)-3/2*ln(sec(d*x+c)+tan(d*x+c)))+2*a*b*(
-sin(d*x+c)+ln(sec(d*x+c)+tan(d*x+c)))+a^2*sin(d*x+c))

________________________________________________________________________________________

Maxima [A]
time = 0.29, size = 105, normalized size = 1.69 \begin {gather*} -\frac {b^{2} {\left (\frac {2 \, \sin \left (d x + c\right )}{\sin \left (d x + c\right )^{2} - 1} + 3 \, \log \left (\sin \left (d x + c\right ) + 1\right ) - 3 \, \log \left (\sin \left (d x + c\right ) - 1\right ) - 4 \, \sin \left (d x + c\right )\right )} - 4 \, a b {\left (\log \left (\sin \left (d x + c\right ) + 1\right ) - \log \left (\sin \left (d x + c\right ) - 1\right ) - 2 \, \sin \left (d x + c\right )\right )} - 4 \, a^{2} \sin \left (d x + c\right )}{4 \, d} \end {gather*}

Verification of antiderivative is not currently implemented for this CAS.

[In]

integrate(cos(d*x+c)*(a+b*tan(d*x+c)^2)^2,x, algorithm="maxima")

[Out]

-1/4*(b^2*(2*sin(d*x + c)/(sin(d*x + c)^2 - 1) + 3*log(sin(d*x + c) + 1) - 3*log(sin(d*x + c) - 1) - 4*sin(d*x
 + c)) - 4*a*b*(log(sin(d*x + c) + 1) - log(sin(d*x + c) - 1) - 2*sin(d*x + c)) - 4*a^2*sin(d*x + c))/d

________________________________________________________________________________________

Fricas [A]
time = 1.76, size = 106, normalized size = 1.71 \begin {gather*} \frac {{\left (4 \, a b - 3 \, b^{2}\right )} \cos \left (d x + c\right )^{2} \log \left (\sin \left (d x + c\right ) + 1\right ) - {\left (4 \, a b - 3 \, b^{2}\right )} \cos \left (d x + c\right )^{2} \log \left (-\sin \left (d x + c\right ) + 1\right ) + 2 \, {\left (2 \, {\left (a^{2} - 2 \, a b + b^{2}\right )} \cos \left (d x + c\right )^{2} + b^{2}\right )} \sin \left (d x + c\right )}{4 \, d \cos \left (d x + c\right )^{2}} \end {gather*}

Verification of antiderivative is not currently implemented for this CAS.

[In]

integrate(cos(d*x+c)*(a+b*tan(d*x+c)^2)^2,x, algorithm="fricas")

[Out]

1/4*((4*a*b - 3*b^2)*cos(d*x + c)^2*log(sin(d*x + c) + 1) - (4*a*b - 3*b^2)*cos(d*x + c)^2*log(-sin(d*x + c) +
 1) + 2*(2*(a^2 - 2*a*b + b^2)*cos(d*x + c)^2 + b^2)*sin(d*x + c))/(d*cos(d*x + c)^2)

________________________________________________________________________________________

Sympy [F]
time = 0.00, size = 0, normalized size = 0.00 \begin {gather*} \int \left (a + b \tan ^{2}{\left (c + d x \right )}\right )^{2} \cos {\left (c + d x \right )}\, dx \end {gather*}

Verification of antiderivative is not currently implemented for this CAS.

[In]

integrate(cos(d*x+c)*(a+b*tan(d*x+c)**2)**2,x)

[Out]

Integral((a + b*tan(c + d*x)**2)**2*cos(c + d*x), x)

________________________________________________________________________________________

Giac [A]
time = 0.78, size = 104, normalized size = 1.68 \begin {gather*} \frac {4 \, a^{2} \sin \left (d x + c\right ) - 8 \, a b \sin \left (d x + c\right ) + 4 \, b^{2} \sin \left (d x + c\right ) + {\left (4 \, a b - 3 \, b^{2}\right )} \log \left ({\left | \sin \left (d x + c\right ) + 1 \right |}\right ) - {\left (4 \, a b - 3 \, b^{2}\right )} \log \left ({\left | \sin \left (d x + c\right ) - 1 \right |}\right ) - \frac {2 \, b^{2} \sin \left (d x + c\right )}{\sin \left (d x + c\right )^{2} - 1}}{4 \, d} \end {gather*}

Verification of antiderivative is not currently implemented for this CAS.

[In]

integrate(cos(d*x+c)*(a+b*tan(d*x+c)^2)^2,x, algorithm="giac")

[Out]

1/4*(4*a^2*sin(d*x + c) - 8*a*b*sin(d*x + c) + 4*b^2*sin(d*x + c) + (4*a*b - 3*b^2)*log(abs(sin(d*x + c) + 1))
 - (4*a*b - 3*b^2)*log(abs(sin(d*x + c) - 1)) - 2*b^2*sin(d*x + c)/(sin(d*x + c)^2 - 1))/d

________________________________________________________________________________________

Mupad [B]
time = 14.31, size = 148, normalized size = 2.39 \begin {gather*} \frac {b\,\mathrm {atanh}\left (\mathrm {tan}\left (\frac {c}{2}+\frac {d\,x}{2}\right )\right )\,\left (4\,a-3\,b\right )}{d}-\frac {\left (2\,a^2-4\,a\,b+3\,b^2\right )\,{\mathrm {tan}\left (\frac {c}{2}+\frac {d\,x}{2}\right )}^5+\left (-4\,a^2+8\,a\,b-2\,b^2\right )\,{\mathrm {tan}\left (\frac {c}{2}+\frac {d\,x}{2}\right )}^3+\left (2\,a^2-4\,a\,b+3\,b^2\right )\,\mathrm {tan}\left (\frac {c}{2}+\frac {d\,x}{2}\right )}{d\,\left (-{\mathrm {tan}\left (\frac {c}{2}+\frac {d\,x}{2}\right )}^6+{\mathrm {tan}\left (\frac {c}{2}+\frac {d\,x}{2}\right )}^4+{\mathrm {tan}\left (\frac {c}{2}+\frac {d\,x}{2}\right )}^2-1\right )} \end {gather*}

Verification of antiderivative is not currently implemented for this CAS.

[In]

int(cos(c + d*x)*(a + b*tan(c + d*x)^2)^2,x)

[Out]

(b*atanh(tan(c/2 + (d*x)/2))*(4*a - 3*b))/d - (tan(c/2 + (d*x)/2)^5*(2*a^2 - 4*a*b + 3*b^2) - tan(c/2 + (d*x)/
2)^3*(4*a^2 - 8*a*b + 2*b^2) + tan(c/2 + (d*x)/2)*(2*a^2 - 4*a*b + 3*b^2))/(d*(tan(c/2 + (d*x)/2)^2 + tan(c/2
+ (d*x)/2)^4 - tan(c/2 + (d*x)/2)^6 - 1))

________________________________________________________________________________________